home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 14 / Mac Magazin and MacEasy Magazine CD - Issue 14.iso / Wissenschaft & Technik / Tools Plus 2.6.1 Evaluation Kit / Tools Plus 2.6.1 / User Manual / 17-Dynamic Alerts < prev    next >
INI File  |  1994-09-17  |  11KB  |  173 lines

  1. [Display using Monaco 9]
  2.  
  3.  
  4. 17  Dynamic Alerts
  5. ``````````````````
  6.  
  7.   Dynamic Alerts are very similar to the Macintosh’s alerts, only they are much better in most situations.  They automatically change size and shape to accommodate the text that is displayed in them, and they are always centered on the main monitor.  It’s like having hundreds of custom alerts available, without having to design any of them!
  8.  
  9.   When a Dynamic Alert is displayed, it optionally beeps the user and the cursor is changed to the Macintosh arrow.  The alert box is automatically sized to accommodate the text specified by your application, and it is centered on the main monitor to be aesthetically pleasing.  An icon can optionally be displayed in the top left corner of the alert.  Your application specifies the combination of buttons that appear at the bottom of the alert.
  10.  
  11.   The AlertBox function automatically polls for mouse clicks and typing events.  When the user clicks one of the buttons, or types Return or Enter to activate a default button, the alert box disappears and control is returned to your application.  The AlertBox function returns the value of the button that was selected by the user.
  12.  
  13.  
  14.  
  15.  
  16.  
  17. Icons
  18. `````
  19.   When Tools Plus draws the icon in the Dynamic Alert, it does so by accessing an icon family and by being sensitive to the settings of the monitor on which the icon is being displayed.  This means that it displays the best available icon (cicn, icl8, icl4, ICN#, or ICON resource) for the target monitor.  You can define ‘cicn’ or ‘icl8’ icons for use with monitors set to 8-bits or higher, ‘icl4’ icons for monitors set to 4-bits or higher, and ‘ICN#’ or ‘ICON’ icons for monitors set to 1-bit or higher.  For more details about how icons are displayed, see the DrawIcon procedure which is used by AlertBox to draw the icon.
  20.  
  21.   The System file includes 3 icons that are ready for your use.  These are the “stop”, “note”, and “caution” icons as illustrated below.  Constants have been defined to let you use these system icons without system compatibility concerns.
  22.  
  23.  
  24.  
  25.  
  26. Text
  27. ````
  28.   The text displayed by Dynamic Alerts is automatically split into multiple lines by using word-wrap if necessary.  AlertBox adjusts the box’s width to make the length of multiple lines as similar as possible.  A Carriage Return (ASCII code $0D) can be used within the text to start a new line.  You can use the ReturnKey constant to make your program more readable.  This lets you form an alert box with multiple lines of text by using a single line of source code in your program.
  29.  
  30.   A Dynamic Alert’s text is left-aligned unless it has no buttons, in which case the text is centered.
  31.  
  32.  
  33.  
  34.  
  35.  
  36. Buttons
  37. ```````
  38.   Dynamic Alerts can display up to three buttons, including an optional default button.  The default button is outlined with a border and is automatically selected if the user presses the Return or Enter key.  Several common button combinations have been defined for you as constants.  Later in this manual, you will be shown how to define your own button combinations.
  39.  
  40.  
  41.  
  42.  
  43.  
  44. Function’s Value
  45. ````````````````
  46.   The AlertBox function returns with a value that indicates which button was clicked by the user.  If AlertBox displays an alert with no buttons, it returns with a value of 1.  Constants have been defined to let your application match the function’s value to a button name more easily.
  47.  
  48.  
  49.  
  50.  
  51.  
  52. Automatic User Notification
  53. ```````````````````````````
  54.   If your application is running under System 6’s MultiFinder or System 7, Dynamic Alerts automatically make use of the Macintosh toolbox’s Notification Manager.  The Notification Manager is used to tell the user that there is something happening they need, or want to be aware of in an inactive application.  An example of the Notification Manager at work is when Print Monitor tells your application it needs a sheet of paper to be inserted for a manual page feed.
  55.  
  56.   If your application is inactive when it uses the AlertBox routine, Tools Plus notifies the user by displaying a notification dialog.  Your application can customize the notification by using the SetNotification routine.
  57.  
  58.  
  59. ------------------------------------------------------------------------
  60.  
  61. AlertBox
  62. ````````
  63. Display a dynamic alert box.
  64.  
  65.    pascal pascal short AlertBox (short theIcon, Str255 AlertText,
  66.                  long AlertCode);
  67.  
  68.    function AlertBox (theIcon: INTEGER; AlertText: STRING;
  69.                  AlertCode: LONGINT): INTEGER;
  70.  
  71.   TheIcon is the icon ID that is displayed in the alert.  If the icon ID you specify does not exist, then the noteIcon is displayed in its place.  Your application can specify any icon it wants, providing the icon resource exists in either the System file or your application.  For more details about how the icon is drawn, see the DrawIcon procedure which is used by AlertBox to draw the icon.
  72.  
  73.   AlertText is the text that is displayed in the Dynamic Alert.  A Carriage Return (ASCII code $0D) can be used in the text to start a new line.  You can use the ReturnKey constant to make your program more readable.  A Dynamic Alert’s text is left-aligned unless the alert has no buttons, in which case the text is centered.
  74.  
  75.   AlertCode specifies the button layout that appears in the Dynamic Alert.  See “Custom Button Combinations” (below) to define your own button layouts.
  76.  
  77.   The AlertBox function returns with a value that indicates which button was clicked by the user.  If AlertBox displays an alert with no buttons, it always returns with a value of 1.  Constants have been defined to let your application match the function’s value to a button name more easily.
  78.  
  79.  
  80.  
  81. Custom Button Combinations
  82. ``````````````````````````
  83. AlertCode lets you specify the button layout that appears on Dynamic Alerts.  This code is a long integer whose value is broken into 5 single-digit numbers, each of which specifies something about the button combination.
  84.  
  85.  
  86.      (1) Number of buttons displayed in the alert [0 to 3]
  87.     /
  88.    /  (2) Default button position [1 to 3, from right to left].  0 if no
  89.    |  /   default button
  90.    | /
  91.    |/  (3) 1st button name [from 1 to 7, rightmost button].  0 if no
  92.    ||  /   button in this position.
  93.    || /
  94.    ||/  (4) 2nd button name [from 1 to 7, second from right].  0 if no
  95.    |||  / button in this position.
  96.    ||| /
  97.    |||/  (5) 3rd button name [from 1 to 7, third from right].  0 if no
  98.    ||||  /   button in this position.
  99.    |||| /
  100.    ||||/
  101.    33243 AlertCode means: 3 buttons in the alert
  102.                           3rd button from right is the default
  103.                           button #2 (Cancel) is 1st button from right
  104.                           button #4 (No) is 2nd button from right
  105.                           button # 3 (Yes) is 3rd button from right
  106.                              (the default)
  107.  
  108.  
  109.   Single button alerts have the button centered between the left and right side of the alert box.  Two button alerts have their buttons placed side by side in the bottom right corner of the alert.  Three button alerts have the first button placed on the bottom right side of the box, and the next two are paired off further to the left.
  110.  
  111.   If the AlertCode is negative, the Dynamic Alert doesn’t beep when displayed.  We strongly recommend that you define your own custom alert codes as constants, then use those constants throughout your application to make your source code more readable.
  112.  
  113.  
  114.   CONST                    {Icon IDs for alert icons…             }
  115.     NoIcon        =-32768  {no icon displayed in alert box        }
  116.     stopIcon      = 0;     {stopIcon will automatically access    }
  117.     noteIcon      = 1;     {   ID = 3 in system files version 5   }
  118.     cautionIcon   = 2;     {   or 6.                              }
  119.  
  120.                            {Dynamic Alert buttons…                }
  121.     OkAltBut      = 1;     {OK                                    }
  122.     CanAltBut     = 2;     {Cancel                                }
  123.     YesAltBut     = 3;     {Yes                                   }
  124.     NoAltBut      = 4;     {No                                    }
  125.     ContAltBut    = 5;     {Continue                              }
  126.     SkipAltBut    = 6;     {Skip                                  }
  127.     QuitAltBut    = 7;     {Quit                                  }
  128.  
  129.                            {Dynamic Alert button combinations…    }
  130.     NoButtonAlert =     0; {No buttons                            }
  131.     OkAlert       = 11100; {OK              (OK default)          }
  132.     CanAlert      = 11200; {Cancel          (Cancel default)      }
  133.     OkCanAlert    = 22210; {OK + Cancel     (OK default)          }
  134.     CanOkAlert    = 21210; {OK + Cancel     (Cancel default)      }
  135.     YesNoAlert    = 22430; {Yes/No          (Yes default)         }
  136.     NoYesAlert    = 21430; {Yes/No          (No default)          }
  137.     YesNoCanAlert = 33243; {Yes/No + Cancel (Yes default)         }
  138.     NoYesCanAlert = 32243; {Yes/No + Cancel (No default)          }
  139.  
  140.  
  141. Note: (System 5 and System 6’s Finder only) It is possible for your
  142.       application to call AlertBox when none of its windows are active.
  143.       An example of this occurs as follows: [1] user enters text in an
  144.       editing field on window “a”, [2] user opens a desk accessory,
  145.       [3] user clicks on another window (“b”) belonging to your
  146.       application, [4] your application determines that the user cannot
  147.       activate window “b” until the field in window “a” is corrected, so
  148.       it displays a Dynamic Alert stating so.
  149.         Whenever a Dynamic Alert is called, it automatically insures
  150.       that the front most window belonging to your application is active
  151.       before the alert is displayed.
  152.  
  153.  
  154. ------------------------------------------------------------------------
  155.  
  156. AlertButtonName
  157. ```````````````
  158. Change the button title on dynamic alert boxes.
  159.  
  160.    pascal void AlertButtonName (int Button, Str255 Title);
  161.  
  162.    procedure AlertButtonName(Button: INTEGER; Title: STRING);
  163.  
  164. Tools Plus provides seven different button titles that may be used in various combinations on dynamic alert boxes.  Although button titles and button number constants are provided for only seven buttons (as detailed in AlertBox), a total of nine buttons are available for use.
  165.  
  166. Button specifies the button number (from 1 to 9) that is affected.
  167.  
  168. Title specifies the button’s title that will appear on all subsequent Dynamic Alerts.  The title may be up to 9 characters long.  The size of the buttons on a dynamic alert box does not change to accommodate longer titles.  The specified title stays in effect until it is explicitly changed by your application.  If a null string is provided, the button resumes its default title.
  169.  
  170. Your application can rename any or all the button titles as required, but keep in mind that the constants defined for the AlertCode and buttons will not work correctly because buttons have been renamed.
  171.  
  172. ------------------------------------------------------------------------
  173.